package com.boardgame.gwt.entity;

import com.boardgame.gwt.data.BaseGame;
import com.boardgame.gwt.enums.GameStatus;
import com.boardgame.gwt.enums.GameType;
import lombok.*;

import javax.persistence.*;
import java.util.Date;

/**
 * Created by pdybka on 30.05.16.
 * 游戏信息
 */

//@Check(constraints = "first_player_piece_code = 'O' or first_player_piece_code = 'X' " +
//        "and game_type = 'COMPUTER' or game_type = 'COMPETITION' " +
//        "and game_status = 'IN_PROGRESS' or game_status = 'FIRST_PLAYER_WON' or game_status = 'SECOND_PLAYER_WON'" +
//        "or game_status = 'TIE' or game_status = 'WAITS_FOR_PLAYER' ")
//@NoArgsConstructor
//@AllArgsConstructor
@Entity
@Data
@Table(name = "gwt_game_info")
public class GwtGameDbInfo  extends BaseGame {

    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    @Column(name = "id", nullable = false)
    private Long id;

    /**
     * 创建时间
     */
    @Column(name = "created", nullable = false)
    private Date created;

    /**
     * 创建用户
     */
    @Column(name = "create_user", nullable = false)
    private int createUser;

//    @ManyToOne
//    @JoinColumn(name = "first_player_id", nullable = false)
//    private GwtPlayer firstPlayer;
//
//    @ManyToOne
//    @JoinColumn(name = "second_player_id", nullable = true)
//    private GwtPlayer secondPlayer;
//
//
//    @ManyToOne
//    @JoinColumn(name = "third_player_id", nullable = true)
//    private GwtPlayer thirdPlayer;
//
//    @ManyToOne
//    @JoinColumn(name = "forth_player_id", nullable = true)
//    private GwtPlayer forthPlayer;

    /**
     * 玩家熟练
     */
    @Column(name = "player_number", nullable = false)
    private int playerNumber;
    /**
     * 游戏类型
     */
    @Enumerated(EnumType.STRING)
    private GameType gameType;

    /**
     * 邮箱状态
     */
    @Enumerated(EnumType.STRING)
    private GameStatus gameStatus;

    /**
     * 游戏日志
     */
    @Column(name = "log_info")
    private String logInfo;

    @Column(name = "game_name", nullable = false)
    private String gameName;
}
